﻿using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


public class ResourceFilter : Attribute, IResultFilter
{
    public void OnResultExecuted(ResultExecutedContext context)
    {
        //throw new NotImplementedException();
    }

    public void OnResultExecuting(ResultExecutingContext context)
    {
        if(!context.HttpContext.Request.Path.StartsWithSegments("/Logging"))
        Server.Utils.LogUtil.LogInfo(Server.Utils.LogUtil.BuildRequetLog(context.HttpContext.Request, ""));
        // 自动刷新Token
        string token = Server.Utils.JwtUtil.CheckOverdue(context.HttpContext.Request.Headers["token"].ToString());
        if (token != null)
        {
            context.HttpContext.Response.Headers.Add("token", token);
        }

    }
}

